define(()=>{
    return function(id, price) {
        'use strict';
        const productMsg = localStorage.getItem("productMsg") ? JSON.parse(localStorage.getItem("productMsg")) : [];
        if(productMsg.length < 1){
            productMsg.push({
                id:id,
                num:1,
                flag:1,
                price:price
            })
        }else{
            let i = 0;
            const f = productMsg.some((val,idx)=>{
                i = idx;
                return val.id === id;
            })
            if(f){
                productMsg[i].num++;
            }else{
                productMsg.push({
                    id:id,
                    num:1,
                    flag:1,
                    price:price
                })
            }
        }
        localStorage.setItem("productMsg",JSON.stringify(productMsg));
    }
    
});